package com.csp.mingyue.system.controller;

import com.csp.mingyue.common.core.vo.R;
import com.csp.mingyue.system.api.entity.SysUser;
import com.csp.mingyue.system.service.SysUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author Strive
 * @since 2023-06-06 03:15:20
 */
@Tag(name = "用户管理模块")
@RestController
@RequestMapping("/sysUser")
@RequiredArgsConstructor
public class SysUserController {

	private final SysUserService sysUserService;

	@Operation(summary = "获取所有用户信息")
	@GetMapping("getSysUsers")
	public R<List<SysUser>> getSysUsers() {
		return R.ok(sysUserService.list());
	}

	@Operation(summary = "通过用户名查询用户信息")
	@GetMapping("getSysUserInfoByUsername")
	@Parameters({ @Parameter(name = "username", description = "用户名", required = true) })
	public R<SysUser> getSysUserInfoByUsername(String username) {
		return R.ok(sysUserService.getSysUserInfoByUsername(username));
	}

}
